/*     */ package com.dp.service.impl;
/*     */ 
/*     */ import com.dp.service.impl3.BaseImpl;
/*     */ import com.dp.util.BookConfig;
/*     */ import com.dp.util.DataMap;
/*     */ import com.dp.util.PageBean;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.stereotype.Service;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ 
/*     */ @Service
/*     */ @Transactional
/*     */ public class ReleaseBean extends BaseImpl
/*     */ {
/*  21 */   private static Logger log = Logger.getLogger(ReleaseBean.class);
/*     */ 
/*     */   public ArrayList getChooseChannel(DataMap hashMap)
/*     */   {
/*  27 */     String sql = "select channel_id, service_code, channel_name, channel_comment, function_name, status, ordered, created_date, previous_id, primal_id, level, channel_type, channel_hot_topics, channel_classifying_label from t_channels ch where ch.channel_id in ";
/*  28 */     sql = sql + 
/*  29 */       " (select uc.channel_id from t_version_channels uc " + 
/*  30 */       "WHERE  (uc.function_name='LAST' OR uc.function_name='CHANNELSONG') and uc.channelversionid='" + 
/*  31 */       hashMap.get("channelversionid") + "') ";
/*     */     try {
/*  33 */       return queryALLResultSet(sql); } catch (Exception e) {
/*     */     }
/*  35 */     return null;
/*     */   }
/*     */ 
/*     */   public ArrayList getNotChooseChannel(DataMap hashMap)
/*     */   {
/*  40 */     String sql = "select channel_id, service_code, channel_name, channel_comment, function_name, status, ordered, created_date, previous_id, primal_id, level, channel_type, channel_hot_topics, channel_classifying_label from t_channels ch WHERE ch.status='" + 
/*  41 */       BookConfig.channel_status_enable + 
/*  42 */       "' AND (ch.function_name='" + BookConfig.channel_last + 
/*  43 */       "' OR ch.function_name='" + BookConfig.channel_song + "') ";
/*     */ 
/*  45 */     Object channelversionid = hashMap.get("channelversionid");
/*  46 */     if (super.StringIsNull(channelversionid)) {
/*  47 */       sql = sql + 
/*  48 */         " and ch.channel_id not in (select channel_id from t_version_channels ca WHERE (ca.function_name='" + 
/*  49 */         BookConfig.channel_last + "' OR ca.function_name='" + 
/*  50 */         BookConfig.channel_song + "') AND ";
/*  51 */       sql = sql + " ca.channelversionid='" + channelversionid + "')";
/*     */     }
/*     */     try
/*     */     {
/*  55 */       return queryALLResultSet(sql); } catch (Exception e) {
/*     */     }
/*  57 */     return null;
/*     */   }
/*     */ 
/*     */   public String getVersion()
/*     */   {
/*  62 */     String sql = "select channelversionid from t_channelversions where version=(select max(version) from t_channelversions) ";
/*     */     try
/*     */     {
/*  65 */       return queryOne(sql); } catch (Exception e) {
/*     */     }
/*  67 */     return null;
/*     */   }
/*     */ 
/*     */   public String getVersionInt()
/*     */   {
/*  72 */     String sql = "select max(version) from t_channelversions ";
/*     */     try
/*     */     {
/*  75 */       return queryOne(sql); } catch (Exception e) {
/*     */     }
/*  77 */     return null;
/*     */   }
/*     */ 
/*     */   public String getNowVersionId()
/*     */   {
/*  82 */     String sql = "SELECT catlogid FROM  news_catlog nc WHERE nc.isnowpublish='1'";
/*     */     try {
/*  84 */       return queryOne(sql); } catch (Exception e) {
/*     */     }
/*  86 */     return null;
/*     */   }
/*     */ 
/*     */   public String getNowVersionId(int type)
/*     */   {
/*  91 */     String sql = "select channelversionid from t_channelversions t where activedate=( select max(activedate) ver from t_channelversions where activedate<now())";
/*     */ 
/*  93 */     if (type == 2)
/*  94 */       sql = "select channelversionid from t_channelversions t where version=( select max(version) ver from t_channelversions where activedate<now() )";
/*     */     try
/*     */     {
/*  97 */       return queryOne(sql); } catch (Exception e) {
/*     */     }
/*  99 */     return null;
/*     */   }
/*     */ 
/*     */   public String getchannelbyCatlogid(int catlogid)
/*     */   {
/* 104 */     String sql = "SELECT channelid FROM  news_catlog_channel where catlogid = " + 
/* 105 */       catlogid;
/*     */     try {
/* 107 */       return queryOne(sql); } catch (Exception e) {
/*     */     }
/* 109 */     return null;
/*     */   }
/*     */ 
/*     */   public ArrayList getNowFirstChannel(String channelversionid)
/*     */   {
/* 115 */     String sql = "SELECT nef.channel_id,nb.buttonname,nb.buttontext, tc.function_name,nct.channelid FROM news_extends_firstchannel nef,news_extends_firstchannel_buttons nfb,news_buttons nb, news_contenttype nct , t_channels tc WHERE  (nb.buttontype='3' or nb.buttontype='6') AND nef.channelid = nfb.channelid AND nfb.buttonid = nb.buttonid AND nb.buttoncontenttype = nct.newscontenttype AND tc.channel_id = nef.channel_id ";
/*     */ 
/* 122 */     if (super.StringIsNull(channelversionid)) {
/* 123 */       sql = sql + " AND nef.channelid='" + channelversionid + "'";
/*     */     }
/* 125 */     sql = sql + " order by nfb.buttonorder";
/*     */     try {
/* 127 */       return queryALLResultSet(sql); } catch (Exception e) {
/*     */     }
/* 129 */     return null;
/*     */   }
/*     */ 
/*     */   public ArrayList getNowNormalChannel(String channel_id)
/*     */   {
/* 134 */     String sql = " SELECT tc.channel_id, a.channleid, tc.function_name, tc.channel_name  FROM news_extends_channel a,news_extends_firstchannel_channels b , t_channels tc WHERE a.channleid=b.channleid AND a.channel_id = tc.channel_id ";
/*     */ 
/* 137 */     if (super.StringIsNull(channel_id)) {
/* 138 */       sql = sql + " AND b.channelid='" + channel_id + "'";
/*     */     }
/* 140 */     sql = sql + " order by b.channelorder";
/*     */     try {
/* 142 */       return queryALLResultSet(sql); } catch (Exception e) {
/*     */     }
/* 144 */     return null;
/*     */   }
/*     */ 
/*     */   public ArrayList getNowContent(String channel_id)
/*     */   {
/* 149 */     String sql = "SELECT nect.channleid,nect.cid,nect.titleorder,nect.contentstatus,nect.istest,nect.isnew,nc.cid, nc.contentid,nc.contenttitle,nc.contenticon,nc.contenttext,nc.note,nc.contentsource,nc.newstype,nc.contenthtml,nc.updatetime,nc.contentsummary,nc.allow_scoring,nc.allow_comments,nc.weburl       FROM news_extends_channel_title nect, news_contenttitle nc WHERE nect.cid = nc.cid AND nect.istest='1' AND nect.isnew='1'";
/*     */ 
/* 153 */     if (super.StringIsNull(channel_id)) {
/* 154 */       sql = sql + " AND nect.channleid='" + channel_id + "'";
/*     */     }
/*     */ 
/* 157 */     sql = sql + " ORDER BY nect.titleorder";
/*     */     try {
/* 159 */       return queryALLResultSet(sql); } catch (Exception e) {
/*     */     }
/* 161 */     return null;
/*     */   }
/*     */ 
/*     */   public ArrayList getNowResource(String contentid)
/*     */   {
/* 180 */     String sql = "select tr.*,tuc.ua_class_info from t_resources tr left join t_ua_class tuc on tr.useragents=tuc.ua_class_id ,t_contents tc , t_resource_content rc WHERE rc.resourceid=tr.resourceid AND rc.contentid=tc.contentid ";
/*     */ 
/* 183 */     if (super.StringIsNull(contentid)) {
/* 184 */       sql = sql + " AND rc.contentid='" + contentid + "'";
/*     */     }
/*     */     try
/*     */     {
/* 188 */       return queryALLResultSet(sql); } catch (Exception e) {
/*     */     }
/* 190 */     return null;
/*     */   }
/*     */ 
/*     */   public boolean insertChannelVersion(DataMap hashMap)
/*     */   {
/* 196 */     String version = getVersionInt();
/* 197 */     if ((version == null) || (version.equals(""))) {
/* 198 */       version = "0";
/*     */     }
/* 200 */     String sql = "insert into t_channelversions (channelversionid,service_code,version,createddate,activedate)VALUES( ";
/*     */ 
/* 202 */     String version_id = BaseImpl.ObjectToStringDB(hashMap.get("version_id"));
/* 203 */     String service_code = BaseImpl.ObjectToStringDB(hashMap
/* 204 */       .get("service_code"));
/*     */ 
/* 206 */     String employee_id = BaseImpl.ObjectToStringDB(hashMap.get("employee_id"));
/* 207 */     String content_name = BaseImpl.ObjectToStringDB(hashMap
/* 208 */       .get("content_name"));
/* 209 */     int temp_version = Integer.valueOf(version).intValue() + 1;
/*     */ 
/* 211 */     String create_date = BaseImpl.ObjectToStringDB(BaseImpl.getNowTime());
/* 212 */     String active_date = BaseImpl.ObjectToStringDB(hashMap.get("active_date"));
/*     */ 
/* 214 */     sql = sql + version_id + ",";
/* 215 */     sql = sql + service_code + ",";
/* 216 */     sql = sql + temp_version + ",";
/* 217 */     sql = sql + create_date + ",";
/* 218 */     sql = sql + active_date + ")";
/*     */ 
/* 220 */     String allChannelid = (String)hashMap.get("channelid");
/*     */ 
/* 229 */     String[] sql2 = publishChannel(version_id, allChannelid);
/*     */     String[] sqlStr;
/* 230 */     if (sql2 != null) {
/* 231 */        sqlStr = new String[2 + sql2.length];
/* 232 */       sqlStr[0] = sql;
/*     */ 
/* 234 */       for (int i = 0; i < sql2.length; i++)
/* 235 */         sqlStr[(1 + i)] = sql2[i];
/*     */     }
/*     */     else {
/* 238 */       sqlStr = new String[2];
/* 239 */       sqlStr[0] = sql;
/*     */     }
/*     */ 
/*     */     try
/*     */     {
/* 244 */       return execTransaction(sqlStr); } catch (Exception e) {
/*     */     }
/* 246 */     return false;
/*     */   }
/*     */ 
/*     */   public String[] publishChannel(String version_id, String allChannelid)
/*     */   {
/* 251 */     String[] sql = (String[])null;
/* 252 */     HashMap map = new HashMap();
/* 253 */     String content_id_list = allChannelid;
/* 254 */     if ((content_id_list != null) && (!content_id_list.equals(""))) {
/* 255 */       String[] c_id_strList = content_id_list.split(",");
/* 256 */       sql = new String[c_id_strList.length];
/* 257 */       for (int i = 0; i < c_id_strList.length; i++) {
/* 258 */         String channel_id = c_id_strList[i];
/*     */ 
/* 260 */         String channelAll = "";
/* 261 */         String temp_channel = "";
/* 262 */         while (!channel_id.equals(temp_channel)) {
/* 263 */           temp_channel = channel_id;
/* 264 */           if (map.get(temp_channel) != null)
/*     */             break;
/* 266 */           String sql0 = "select previous_id from t_channels where channel_id=" + 
/* 267 */             temp_channel;
/*     */           try {
/* 269 */             channel_id = "'" + queryOne(sql0) + "'";
/* 270 */             channelAll = channelAll + temp_channel + ",";
/* 271 */             map.put(temp_channel, temp_channel);
/*     */           }
/*     */           catch (Exception e1)
/*     */           {
/* 275 */             e1.printStackTrace();
/*     */           }
/*     */         }
/* 278 */         if (!channelAll.equals(""))
/* 279 */           channelAll = channelAll.substring(0, 
/* 280 */             channelAll.length() - 1);
/* 281 */         sql[i] = 
/* 285 */           ("insert into t_version_channels(channelversionid,channel_id,channel_name,function_name,ordered,created_date,previous_id,primal_id,level)  select " + 
/* 283 */           version_id + 
/* 284 */           ",channel_id,channel_name,function_name,ordered,created_date,previous_id,primal_id,level from t_channels where channel_id in (" + 
/* 285 */           channelAll + ")");
/*     */       }
/*     */     }
/* 288 */     return sql;
/*     */   }
/*     */ 
/*     */   public PageBean releaseList(DataMap hashMap) {
/* 292 */     String sql = "select cv.*,p.* from t_channelversions cv LEFT join t_service_info p on cv.service_code=p.service_code order by cv.createddate desc ";
/*     */     try
/*     */     {
/* 296 */       hashMap.put("sql", sql);
/* 297 */       return new PageBean(hashMap);
/*     */     } catch (Exception e) {
/*     */     }
/* 300 */     return null;
/*     */   }
/*     */ }

/* Location:           C:\Temp\a\com.zip
 * Qualified Name:     com.dp.service.impl.ReleaseBean
 * JD-Core Version:    0.6.2
 */